/*
 * File Name: KeysManager.java
 *
 * Description: 
 *
 * Copyright @ 2005 Thomson Healthcare Inc. All Rights Reserved.
 */

package org.turbobytes.unikey.generator.table;

import java.util.Iterator;
import java.util.NoSuchElementException;

public class KeyList implements Iterable<Long>, Iterator<Long> {

  long lastValue;

  long currentValue;

  long incrementBy;

  public KeyList(long incrementBy) {
    this.incrementBy = incrementBy;
  }

  public long getCurrentValue() {
    return currentValue;
  }

  public void setCurrentValue(long currentValue) {
    this.currentValue = currentValue;
  }

  public long getLastValue() {
    return lastValue;
  }

  public void setLastValue(long lastValue) {
    this.lastValue = lastValue;
  }

  public Iterator<Long> iterator() {
    return this;
  }

  public boolean hasNext() {
    if ((currentValue + incrementBy) > lastValue) {
      return false;
    }
    return true;
  }

  public Long next() {
    if ((currentValue + incrementBy) > lastValue) {
      throw new NoSuchElementException();
    }
    currentValue = currentValue + incrementBy;
    return currentValue;
  }

  public void remove() {
    throw new UnsupportedOperationException();

  }

}
